home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 26.zip / BS1 part 26 / Aztec C v5.2a disk 4.adf / incl52.lzh / stdio.h < prev    next >
C/C++ Source or Header  |  1991-05-22  |  5KB  |  148 lines

  1. /* Copyright 1989 Manx Software Systems, Inc. All rights reserved */
  2.  
  3. #ifndef __STDIO_H
  4. #define    __STDIO_H
  5.  
  6. #include <stdarg.h>
  7.  
  8. # ifndef _SIZE_T
  9. # define _SIZE_T
  10.   typedef unsigned long size_t;
  11. # endif
  12.  
  13. #ifndef NULL
  14. #define NULL ((void *)0)
  15. #endif
  16.  
  17. #define BUFSIZ 1024            /* Default file buffer size */
  18. #define _LBFSIZ 100            /* Line buffer size */
  19.  
  20. #define EOF (-1)
  21.  
  22. #define L_tmpnam 40
  23. #ifndef FOPEN_MAX
  24. #define FOPEN_MAX 20    /* must agree with fcntl.h */
  25. #endif
  26. #define FILENAME_MAX 126
  27. #define TMP_MAX 25
  28.  
  29. #define SEEK_SET 0    /* from beginning of file */
  30. #define SEEK_CUR 1    /* from current position */
  31. #define SEEK_END 2    /* from end of file */
  32.  
  33. #define stdin (&_iob[0])
  34. #define stdout (&_iob[1])
  35. #define stderr (&_iob[2])
  36.  
  37. typedef long int fpos_t;
  38.  
  39. typedef struct __stdio {
  40.     unsigned char *_bp;            /* current position in buffer */
  41.     unsigned char *_bend;        /* last character in buffer + 1 */
  42.     unsigned char *_buff;        /* address of buffer */
  43.     unsigned short _flags;        /* open mode, etc. */
  44.     char _unit;                    /* fd returned by open */
  45.     unsigned char _bytbuf;        /* single byte buffer for unbuffered streams */
  46.     size_t _buflen;                /* length of buffer */
  47.     unsigned short _tmpnum;        /* name of file for temporaries */
  48. } FILE;
  49. extern FILE _iob[];
  50.  
  51. #define _IOMYBUF    0x0001    /* malloced buffer */
  52. #define _IOEOF        0x0002    /* end-of-file encountered */
  53. #define _IOERR        0x0004    /* error occurred */
  54. #define _IOSTRNG    0x0008    /* special string stream */
  55. #define _IOBIN        0x0010    /* file is binary ("b") */
  56. #define _IOLBF        0x0020    /* line buffered */
  57. #define _IOFBF        0x0040    /* fully buffered */
  58. #define _IONBF        0x0080    /* completely unbuffered */
  59. #define _IOCON        0x0100    /* console device */
  60. #define _IOR        0x0200    /* stream opened in read mode */
  61. #define _IOW        0x0400    /* stream opened in write mode */
  62. #define _IORW        0x0800    /* stream opened in update mode */
  63. #define _IOUNG        0x1000    /* ungetc was called */
  64. #define _IOSYNC     0x2000    /* MPW compatibility, 
  65.                              * input triggers fflush() to output fp's.
  66.                              * will synchronize input and output fp's, such that
  67.                               * a read() for an input fp with this bit set will 
  68.                              * first fflush() all output fp's which have the 
  69.                              * _IOSYNC bit set.
  70.                                */
  71. #define _IODIRTY    0x4000    /* buffer has been written */
  72.  
  73. int remove(const char *_filename);
  74. int rename(const char *_old, const char *_new);
  75. FILE *tmpfile(void);
  76. char *tmpnam(char *_s);
  77. int fclose(FILE *_stream);
  78. int fflush(FILE *_stream);
  79. FILE *fopen(const char *_filename, const char *_mode);
  80. FILE *freopen(const char *_filename, const char *_mode, FILE *_stream);
  81. void setbuf(FILE *_stream, char *_buf);
  82. int setvbuf(FILE *_stream, char *_buf, int _mode, size_t _size);
  83. int fprintf(FILE *_stream, const char *_format, ...);
  84. int fscanf(FILE *_stream, const char *_format, ...);
  85. int printf(const char *_format, ...);
  86. int scanf(const char *_format, ...);
  87. int sprintf(char *_s, const char *_format, ...);
  88. int sscanf(const char *_s, const char *_format, ...);
  89. int vfprintf(FILE *_stream, const char *_format, va_list _arg);
  90. int vprintf(const char *_format, va_list _arg);
  91. int vsprintf(char *_s, const char *_format, va_list _arg);
  92. int fgetc(FILE *_stream);
  93. char *fgets(char *_s, int _n, FILE *_stream);
  94. int fputc(int _c, FILE *_stream);
  95. int fputs(const char *_s, FILE *_stream);
  96. int getc(FILE *_stream);
  97. int getchar(void);
  98. char *gets(char *_s);
  99. int putc(int _c, FILE *_stream);
  100. int putchar(int _c);
  101. int puts(const char *_s);
  102. int ungetc(int _c, FILE *_stream);
  103. size_t fread(void *_ptr, size_t _size, size_t _nmemb, FILE *_stream);
  104. size_t fwrite(const void *_ptr, size_t _size, size_t _nmemb, FILE *_stream);
  105. int fgetpos(FILE *_stream, fpos_t *_pos);
  106. int fseek(FILE *_stream, long int _offset, int _whence);
  107. int fsetpos(FILE *_stream, const fpos_t *_pos);
  108. long int ftell(FILE *_stream);
  109. void rewind(FILE *_stream);
  110. void clearerr(FILE *_stream);
  111. int feof(FILE *_stream);
  112. int ferror(FILE *_stream);
  113. void perror(const char *_s);
  114.  
  115. #ifdef __C_MACROS__
  116. #define getc(fp)    ((fp)->_bp < (fp)->_bend ? *(fp)->_bp++ :_filbuf((fp)))
  117. #define putc(c,fp)    ((fp)->_bp < (fp)->_bend ? *(fp)->_bp++ = (c) : \
  118.                                         _flsbuf((fp),(int)(unsigned char)(c)))
  119. #define getchar() getc(stdin)
  120. #define putchar(c) putc((c), stdout)
  121. #define clearerr(fp) ((void)((fp)->_flags &= ~(_IOERR|_IOEOF)))
  122. #define feof(fp) ((fp)->_flags&_IOEOF)
  123. #define ferror(fp) ((fp)->_flags&_IOERR)
  124. #endif
  125.  
  126. #if !__STDC__ /* non ANSI C user-visible stuff */
  127.  
  128. int _flsbuf(FILE *, int);
  129. int _filbuf(FILE *);
  130. void _getbuf(FILE *);
  131. FILE *_fileopen(const char *, const char *, FILE *fp, int);
  132. FILE *_getiob(void);
  133. int _format(FILE *, const char *, va_list);
  134. int format(int (*)(int), const char *, ...);
  135. int _scan(FILE *, const char *, va_list);
  136.  
  137. FILE *fdopen(int, const char *);
  138. #define fileno(fp) ((int)(fp)->_unit)                
  139. #define puterr(c)    (putc((c),stderr))
  140.  
  141. int putw(int _w, FILE *_stream);
  142. int getw(FILE *_stream);
  143.  
  144. #endif /* !__STDC__ */
  145.  
  146. #endif /* _STDIO_H */
  147.  
  148.